const Controller = require('egg').Controller

class GoodsController extends Controller {
    // 商品列表
    async list() {
        const { ctx } =this
        const result = await ctx.service.admin.goods.list(ctx.request.body)
        ctx.body = result;
    }
    // 商品详情
    async details() {
        const { ctx } =this
        const result = await ctx.service.admin.goods.details(ctx.request.body)
        ctx.body = result;
    }
    // (添加/编辑)商品
    async add_redact() {
        const { ctx } = this
        if(ctx.request.body.id) {
            ctx.body = await ctx.service.admin.goods.redact(ctx.request.body)
        }else{
            ctx.body = await ctx.service.admin.goods.add(ctx.request.body)
        }
    }
    // 删除商品
    async del() {
        const { ctx } = this
        const result = await ctx.service.admin.goods.del(ctx.request.body)
        ctx.body = result;
    }
}

module.exports = GoodsController